package com.jcl.core.db.utils;

import com.jcl.core.db.DbConnection;

import java.sql.Connection;

/**
 * @ClassName DataSourceUtils
 * @Author yyliu
 * @Date 2018/12/24 11:34
 * @Version 1.0
 **/
public class DataSourceUtils {

    public static final String DRIVER_CLASS_NAME = "com.mysql.jdbc.Driver";

    public static Boolean testDbConnect(String driverClassName,
                                        String url,
                                        String user,
                                        String password) {
        // 定义连接
        DbConnection connection = new DbConnection();
        Connection conn = connection.setConnection(driverClassName, url, user, password);

        return null == conn ? false : true;
    }

    public static String makeMysqlDriverUrl(String ip, String port, String param, String dbName) {
        String url = "jdbc:mysql://" + ip + ":" + port + "/" + dbName + "?" + param;
        return url;
    }


}
